var express = require('express');
const Result = require('../lib/Result');
const isRule = require('../util/isRule');
const OrderItem = require('../db/models/order/order_item');
var router = express.Router();
/**
 * 商品评论列表,94,17,7
 */
router.get("/:page", (req, res) => {
    let token = req.auth
    if (isRule(token.rule, [94,17,7], res, token.super)) {
        let page=req.params.page
        let limit=req.body.limit?req.body.limit:10
        let title=req.body.title
        OrderItem.getOrderItemList(page,Number(limit),title).then(value=>{
            res.json(Result.success(value))
        })
    }
})
/**
 * 修改商品评论状态,96,17,7
 */
router.post("/:id/update_status", (req, res) => {
    let token = req.auth
    if (isRule(token.rule, [96,17,7], res, token.super)) {
        let status=req.body.status
        OrderItem.updateStatus(status,req.params.id).then(value=>{
            res.json(Result.success(true))
        })
    }
})
/**
 * 回复商品评价,95,17,7
 */
router.post("/review/:id", (req, res) => {
    let token = req.auth
    if (isRule(token.rule, [95,17,7], res, token.super)) {
        let data=req.body.data
        OrderItem.updateExtra(data,req.params.id).then(value=>{
            res.json(Result.success(true))
        })
    }
})
module.exports=router